﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Robot_ui : MonoBehaviour {

    public InputField txtNum;
    public InputField roomID;

    public Text txtIP;
    public Text txtPort;

    public GameObject item;
    public GameObject list;
	// Use this for initialization
	void Start () {
	
	}

    public void OnClickCreate()
    {
        robot.host = txtIP.text;
        robot.port = System.Convert.ToInt32(txtPort.text);
        int num = System.Convert.ToInt32(txtNum.text);
        while(num-- > 0)
        {
            CreateItem();
        }
    }

    public void CreateItem()
    {
        GameObject nobj = GameObject.Instantiate(item);
        nobj.transform.SetParent(list.transform);
        
        robot rbot = nobj.AddComponent<robot>();
        rbot.login(roomID.text);
    }
	// Update is called once per frame
	void Update () {
	
	}
}
